<template>
	<view class="content" v-if="detail.length">
		<view class="content-detail">
			<view class="header-title">
				<view class="title">攻略笔记</view>
				<view class="more" @click="getMore">查看更多 <text class="iconfont">&#xe67f;</text> </view>
			</view>
			<view class="detail">
				<view class="info" v-for="(item,index) in detail" :key="index" @click="gotoStrategy(item.id)">
					<img class="product-img" :src="item.litpic" mode="aspectFill" />
					<view class="introduce">
						<view class="introduce-title">{{item.title}}</view>
						<view class="browse-blogger">
							<view class="blogger">
								<text class="name">{{item.author}}</text>
							</view>
							<view class="browse">
								<text class="iconfont">&#xe670;</text>
								<text class="browse-num" v-if="Number(item.shownum)<999">{{item.shownum}}</text>
								<text class="browse-num" v-else>999+</text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	/**
	 * strategy 攻略模块组件
	 *  productId {Number,String} 产品id
	 *  typeId {Number,String} 产品类型id
	 */
	export default {
		name: "st-strategy",
		props: {
			productId: {
				type: [Number,String],
				default: 0
			},
			typeId:{
				type: [Number,String],
				default: 0
			}
		},
        created() {
			setTimeout(() => {
				this.getStrategy()
			}, 300);
		},
		data() {
			return {
              detail:[]
			};
		},

		methods: {
			//查那看更多
			getMore() {
				uni.navigateTo({
					url: `/subPackages/strategy/list?productId=${this.productId}&typeId=${this.typeId}`
				})
			},
			//去攻略详情
			gotoStrategy(id){
				uni.navigateTo({
					url: `/subPackages/strategy/detail?id=${id}`
				})
			},
            //获取当前产品的相关攻略
			async getStrategy(){
				let res,
				params = {
					method: 'api/v2/article/get_product_article',
					product_id: this.productId,
					type_id: this.typeId
				}
				res = await this.$http(params);
				if(res.status){
					this.detail = res.data
				}
			}
		}
	}
</script>

<style lang="scss">
	.content {
		background: #FFFFFF;
		border-radius: 20rpx;
		margin: 20rpx 0 40rpx;
	}

	.content-detail {
		padding: 32rpx 24rpx 28rpx;
	}

	.header-title {
		display: flex;
		flex-wrap: nowrap;
		justify-content: space-between;
	}

	.title {
		font-size: 34rpx;
		font-weight: bold;
		color: #222222;
		line-height: 44rpx
	}

	.more {
		font-size: 26rpx;
		color: #999999;
		line-height: 44rpx
	}

	.iconfont {
		color: #A0A0A0;
	}

	.detail {
		display: flex;
		flex-wrap: nowrap;
		justify-content: space-between;
	}

	.info {
		margin-top: 32rpx;
	}

	.product-img {
		width: 318rpx;
		height: 318rpx;
		border-radius: 10rpx;
	}

	.introduce {
		width: 318rpx;
		height: 150rpx;
		margin-top: -20rpx;
		position: relative;
		background: #FFFFFF;
		box-shadow: 0rpx 8rpx 20rpx 0rpx rgba(191, 191, 191, 0.15);
		border-radius: 10rpx 10rpx 10rpx 10rpx;
	}

	.introduce-title {
		margin: 0 12rpx 18rpx;
		padding-top: 12rpx;
		font-size: 28rpx;
		font-weight: bold;
		color: #333333;
		line-height: 36rpx;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		white-space: normal;
		overflow: hidden;
	}

	.browse-blogger {
		position: absolute;
		bottom: 20rpx;
		display: flex;
		flex-wrap: nowrap;
		align-items: center;
		justify-content: space-between;
		width: 318rpx;
	}
	.blogger{
		display: flex;
		flex-wrap: nowrap;
		align-items: end;
	}

	.name {
		font-size: 22rpx;
		color: #666666;
		line-height: 28rpx;
		margin-left: 8rpx;
		width: 136rpx;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 1;
		white-space: normal;
		overflow: hidden;
	}

	.browse {
		font-size: 22rpx;
		color: #999999;
		line-height: 28rpx;
		position: absolute;
		display: flex;
		align-items: center;
		right: 12rpx;
		.iconfont{
			margin-top: 5rpx;
		}
	}

	.browse-num {
		margin-left: 8rpx;
	}
</style>